package com.lzw.breezeNovel.webApp.mapper.user;

import com.lzw.breezeNovel.model.entity.pojo.user.UserAtten;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.mapper.user
 * @date 2025/3/25
 * @description
 */
@Mapper
@SuppressWarnings("all")
public interface UserAttenMapper {

    /**
     * 根据用户id和被关注用户id查询
     * @param userId
     * @param ortherId
     * @return
     */
    @Select("select exists(select 1 from user_atten where user_id = #{userId} and orther_id = #{ortherId})")
    int selectByUserIdAndOrtherId(Long userId, Long ortherId);

    /**
     * 插入用户关注记录
     * @param userAtten
     */
    @Insert("insert into user_atten(user_id,orther_id,create_time) values(#{userId},#{ortherId},#{createTime})")
    void insert(UserAtten userAtten);

    /**
     * 根据用户id和被关注用户id删除
     * @param userId
     * @param ortherId
     */
    @Delete("delete from user_atten where user_id = #{userId} and orther_id = #{ortherId}")
    void delByuserIdAndOrtherId(Long userId, Long ortherId);

    /**
     * 根据用户id查询关注列表
     * @param userId
     * @param start
     * @param size
     * @return
     */
    List<UserAtten> selectByUserId(Long userId, Integer start, Integer size);
}
